local UGCPlayerState = {
    --玩家的标识
    TeamIndex = 0
};
 
function UGCPlayerState:GetReplicatedProperties()
    return 
    "TeamIndex"
end

function UGCPlayerState:ReceiveBeginPlay()
    print(string.format("UGCPlayerState:ReceiveBeginPlay[%s]", self.PlayerName));
    self.SuperClass.ReceiveBeginPlay(self);
    
    if self:HasAuthority() == true then 
    else
        --一个队伍仅有一位玩家，所以(self,0)
        if self:GetOwner() == GameplayStatics.GetPlayerController(self, 0) then
            print("UGCPlayerState:ReceiveBeginPlay Set AeroplaneChessMode.OwnerPlayerState");
            Mode.OwnerPlayerState = self;
        end
        self.hasBegunPlay = true
        self:TrySendTeamIndexAssignEvent();
    end
end

function UGCPlayerState:OnRep_TeamIndex()
    print("PlayerPawn.TeamIndex %d"..UGCGameSystem.GameState.PlayerInfos[self.TeamIndex].PlayerPawn.TeamIndex);
    --UGCGameSystem.GameState.PlayerInfos[self.TeamIndex].PlayerPawn.TeamIndex = self.TeamIndex
    print("UGCPlayerState:OnRep_TeamIndexb %d"..self.TeamIndex);
    self:TrySendTeamIndexAssignEvent();
end

-- 如果onrep在beginplay之前调用会有问题，这样规避一下
function UGCPlayerState:TrySendTeamIndexAssignEvent()
    if self.hasBegunPlay and self.TeamIndex ~= 0 then
        print(string.format("UGCPlayerState:TrySendTeamIndexAssignEvent %d", self.TeamIndex));
        --高亮处理？
        --UGCEventSystem:SendEvent(EventType.TeamIndexAssigned, self.TeamIndex, self.PlayerKey);
    end
end

-- function UGCPlayerState:ReceiveTick(DeltaTime)

-- end
-- function UGCPlayerState:ReceiveEndPlay()
 
-- end

return UGCPlayerState;